//
//  RBCollectionReusableView.m
//  zhongzhenglu
//
//  Created by XL on 2022/5/26.
//

#import "RBCollectionReusableView.h"
#import <Masonry.h>
#import <YYCategories.h>

@interface RBCollectionReusableView()

@property(nonatomic, strong) UIView *contentView;

@end

@implementation RBCollectionReusableView

- (void)setHeaderGroupModel: (RBGroupModel *)headerGroupModel
{
    [self.contentView removeAllSubviews];
    UIView *desView;
    if (headerGroupModel.headerView)
    {
        desView = headerGroupModel.headerView;
    }
    [self.contentView addSubview:desView];
    [desView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.mas_equalTo(0);
    }];
}

- (void)setFooterGroupModel:(RBGroupModel *)footerGroupModel
{
    [self.contentView removeAllSubviews];
    UIView *desView;
    if(footerGroupModel.footerView)
    {
        desView = footerGroupModel.footerView;
    }
    [self.contentView addSubview:desView];
    [desView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.mas_equalTo(0);
    }];
}

- (UIView *)contentView
{
    if (!_contentView)
    {
        self.contentView = ({
            UIView *view = UIView.new;
            [self addSubview:view];
            [view mas_makeConstraints:^(MASConstraintMaker *make) {
                make.edges.mas_equalTo(0);
            }];
            view;
        });
    }
    return _contentView;
}

@end
